package com.example;

import com.bstek.ureport.console.UReportServlet;
import com.example.ext.jwt.JwtFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@ImportResource("classpath:context.xml")
@EnableTransactionManagement
@SpringBootApplication
public class ElevatorApplication {

    public static void main(String[] args) {
        SpringApplication.run(ElevatorApplication.class, args);
    }

    @Bean
    public FilterRegistrationBean jwtFilter(){
        final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new JwtFilter());
        //registrationBean.addUrlPatterns("/app/*");
        registrationBean.addUrlPatterns("/api/*");
        return registrationBean;
    }
    /**
     * 测试服务器不支持 内存太小，暂时注释
     */
    @Bean
    public ServletRegistrationBean buildUreportServlet() {
        return new ServletRegistrationBean(new UReportServlet(), "/ureport/*");
    }
}
